<?php
include_once('../lib/Sqlexecutor.php');
include_once('../lib/Login.php');
include_once('../lib/Feedback.php');
include('log4php/Logger.php');

Logger::configure('config.ini');
$logger = Logger::getLogger('intf');

//login
$dbh = new Sqlexecutor('localhost', 'tile', 'tile', 'tile');
$usrid = isset($_REQUEST['usrid']) ? $_REQUEST['usrid'] : 0;
$sessionid = isset($_REQUEST['sessionid']) ? $_REQUEST['sessionid'] : '';

$l = new Login($dbh, $logger);
$info = $l->isLogin($usrid, $sessionid);
if($info != 1)
{
    $res['errno'] = -1;
    $output = json_encode($res); 
    $logger->trace("input: usrid=$usrid, sessionid=$sessionid; res: $output"); 
    echo $output;
    exit;
}


$s = new Feedback($dbh, $logger);
$info = $s->getListByUsrId($usrid);

if($info === false)
{
    $res['errno'] = -100;
}
else
{
    $res['errno'] = 0;
    $res['list'] = $info;
}
$output = json_encode($res);
$logger->trace("input: usrid=$usrid, sessionid=$sessionid; res: $output"); 

echo $output;
